package appConfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type appConfig struct {
	Mysql struct {
		Host     string
		Port     int
		User     string
		Password string
		Database string
	}
	Redis struct {
		Host     string
		Port     int
		Password string
		Database int
	}
	SendSms struct {
		Account  string
		Password string
	}
}

var AppConfig appConfig

func Init() {
	var err error
	viper.SetConfigFile("../appConfig/config.yaml")
	err = viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	err = viper.Unmarshal(&AppConfig)
	if err != nil {
		panic(err)
	}
	fmt.Println("文件配置获取成功")
}
